package com.zhangjie.apipassenger.controller;

import com.zhangjie.apipassenger.service.TokenService;
import com.zhangjie.internalcommon.dto.ResponseResult;
import com.zhangjie.internalcommon.dto.TokenResult;
import com.zhangjie.internalcommon.response.TokenResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: zj
 * @Date: 2024/2/3 - 02 - 03 - 17:43
 * @Description: com.zhangjie.apipassenger.controller
 * @version: 1.0
 */
@RestController
public class TokenController {

    @Autowired
    private TokenService tokenService;

    @PostMapping("/token-refresh")
    public ResponseResult refreshToken(@RequestBody TokenResponse tokenResponse){// 由于TokenResponse中有我们想要的参数refreshToken，习惯性直接使用此bean，没有严格要求

        String refreshTokenSrc = tokenResponse.getRefreshToken();
        System.out.println("原来的 refreshToken：" + refreshTokenSrc);

        return tokenService.refreshToken(refreshTokenSrc);
    }
}
